package com.longrise.android.byjk.plugins.course.batchbuy.batchbuyconfirm;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.longrise.LEAP.Base.Objects.EntityBean;
import com.longrise.android.byjk.R;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by callxkj on 2017/11/21.
 * 批量购买
 */

public class BatchbuyConfirmRcvAdapter extends BaseQuickAdapter<EntityBean, BaseViewHolder> {

    private List<EntityBean> mList = new ArrayList<>();
    private boolean mIsVisiable = true;

    public BatchbuyConfirmRcvAdapter() {
        super(R.layout.item_confirmorder_content);
    }

    /**
     * 设置是否显示最后item的底部下划线
     */
    public void setLastLineVisiable(boolean isVisiable) {
        this.mIsVisiable = isVisiable;
    }

    public void setDatas(EntityBean[] beans) {
        mList.clear();
        for (int x = 0; x < beans.length; x++) {
            mList.add(beans[x]);
        }
        setNewData(mList);
    }

    @Override
    protected void convert(BaseViewHolder helper, EntityBean item) {
        helper.setText(R.id.item_confirm_order_content_xitong, item.getString("grouptypename"));
        helper.setText(R.id.item_confirm_order_content_coursename, item.getString("groupname"));
        int layoutPosition = helper.getLayoutPosition();
        if (layoutPosition == mList.size()) {
            helper.setVisible(R.id.item_confirm_order_content_divider, mIsVisiable);
        }else{
            helper.setVisible(R.id.item_confirm_order_content_divider,true);
        }
    }
}
